﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Reflection;


namespace AspNetCs.Enumerations
{

    public class BindEnumList<TEnum>
    {
        public static Dictionary<string, string> BindEnum()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            Type type=typeof(TEnum);
            NetMuTypeEnum[] values = (NetMuTypeEnum[])Enum.GetValues(type);
            string[] names = (string[])Enum.GetNames(type);
            for (int i = 0; i < values.Length;i++ )
            {
                dic.Add(((int)values[i]).ToString(),names[i]);
            }

            FieldInfo[] fields = type.GetFields();
            //try
            //{
            //    foreach (FieldInfo field in fields)
            //    {
            //        dic.Add(field.GetValue(field.Name).ToString(), field.Name);
            //    }
            //}
            //catch (Exception ex)
            //{

            //}
            return dic;
        }
    }
    
}
